package com.mazewei.dev.dao;

import com.mazewei.dev.entity.Course;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * 课程数据访问接口 - MyBatis Mapper
 */
@Mapper
public interface CourseDao {
    
    /**
     * 根据课程名称查找课程信息
     * @param courName 课程名称
     * @return 课程信息
     */
    @Select("SELECT * FROM course WHERE CourName = #{courName} ORDER BY id DESC LIMIT 1")
    @Results({
        @Result(property = "courNum", column = "CourNum"),
        @Result(property = "courName", column = "CourName")
    })
    Course findByName(@Param("courName") String courName);
    
    /**
     * 根据课程编号查找课程信息
     * @param courNum 课程编号
     * @return 课程信息
     */
    @Select("SELECT * FROM course WHERE CourNum = #{courNum} LIMIT 1")
    @Results({
        @Result(property = "courNum", column = "CourNum"),
        @Result(property = "courName", column = "CourName")
    })
    Course findByCourNum(@Param("courNum") String courNum);
    
    /**
     * 查找所有课程信息
     * @return 课程信息列表
     */
    @Select("SELECT * FROM course")
    @Results({
        @Result(property = "courNum", column = "CourNum"),
        @Result(property = "courName", column = "CourName")
    })
    List<Course> findAll();
    

}